package com.util;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import com.bean.wd_ht_room;
public class Export {  
          
        //建立学生表格  
        public void buildStudentExcel(List list, String sheetname, OutputStream out) {  
            HSSFWorkbook wb = new HSSFWorkbook();  
            HSSFSheet sheet1 = wb.createSheet("sheet1");  
            HSSFRow row = sheet1.createRow((short) 0);
            row.createCell(0).setCellValue("房间ID"); 
            row.createCell(1).setCellValue("项目");  
            row.createCell(2).setCellValue("房间");  
            row.createCell(3).setCellValue("建筑面积");  
            row.createCell(4).setCellValue("套内面积");  
            row.createCell(5).setCellValue("计价方式");  
            row.createCell(6).setCellValue("建筑面积单价");  
            row.createCell(7).setCellValue("套内面积单价");  
            for (int i = 0; i < list.size(); i++) {  
            	wd_ht_room s = (wd_ht_room)list.get(i);  
                row=sheet1.createRow((short)(i+1)); 
                //暂时用此字段代替项目
                row.createCell(0).setCellValue(s.getRoomId());
                row.createCell(1).setCellValue(s.getDeleteUser());  
                row.createCell(2).setCellValue(s.getRoomCode());  
                row.createCell(3).setCellValue(s.getBuildUpArea());  
                row.createCell(4).setCellValue(s.getInnerArea()); 
                //暂时用此字段代替计价方式
                row.createCell(5).setCellValue(s.getUpdateUser());  
                row.createCell(6).setCellValue(s.getUnitPrice());  
                row.createCell(7).setCellValue(s.getInnerPrice());
            }  
            try {  
                out.flush();  
                wb.write(out);  
                out.close();          
            } catch (IOException e) {  
                e.printStackTrace();  
                System.out.println("Out  is  closed ");  
            }  
   }     
}